package com.ruoyi.web.controller.V2.web.conntroller;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.V2.tool.mapper.TelUnbindMapper;
import com.ruoyi.system.V2.tool.service.IErrorInfoService;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.model.domain.ErrorInfo;
import com.ruoyi.system.model.domain.TelUnbind;
import com.ruoyi.system.outto.game.impl.Sample;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;

/**
 * @author lz
 * @version 1.0
 * @date 2022/5/10 18:34
 */
@RestController
@RequestMapping("open/api/qrcode")
public class QRCodeController {


    @Autowired
    private IErrorInfoService errorInfoService;

//    @Resource
//    private GoodsInfoMapper goodsInfoMapper;


    @Resource
    private SysDictDataMapper sysDictDataMapper;

    @Resource
    private TelUnbindMapper telUnbindMapper;

    private static String commonCode = "100";

    @Autowired
    private RedisCache redisCache;
    static String hwTokenxyr = "hwTokenxyr";

    /**
     * 查询游戏类型
     */
    @SneakyThrows
    @PostMapping("/addErrInfo")
    public String GetGameDQ(ErrorInfo errorInfo) {

        errorInfo.setCreateBy("1");
        errorInfo.setCreateTime(new Date());
        errorInfoService.insertErrorInfo(errorInfo);
        System.out.println(errorInfo);
        return "true";

    }
    @PostMapping("/parseCode")
    public String parseCode(@RequestParam("file") MultipartFile file) {

        String url = "";

        List<SysDictData> sysDictDataList = sysDictDataMapper.selectDictDataByType("huaweiyun");
        for (SysDictData sysDictData : sysDictDataList) {
            if (sysDictData.getDictLabel().equals("url")){
                url = sysDictData.getRemark();
            }
//            if (sysDictData.getDictLabel().equals("token")){
//                token = sysDictData.getRemark();
//            }
        }
        Object token = redisCache.getCacheObject(hwTokenxyr);

      //  String url = "https://2a652c69871642dc836b3c073717bd00.apigw.cn-north-4.huaweicloud.com/v1/infers/4f775021-8b28-42b4-a8f3-21f38e7d3d23";
       // String token = "MIIUSgYJKoZIhvcNAQcCoIIUOzCCFDcCAQExDTALBglghkgBZQMEAgEwghJcBgkqhkiG9w0BBwGgghJNBIISSXsidG9rZW4iOnsiZXhwaXJlc19hdCI6IjIwMjMtMDQtMjBUMDc6NDk6MTUuMTg1MDAwWiIsIm1ldGhvZHMiOlsicGFzc3dvcmQiXSwiY2F0YWxvZyI6W10sInJvbGVzIjpbeyJuYW1lIjoidGVfYWRtaW4iLCJpZCI6IjAifSx7Im5hbWUiOiJ0ZV9hZ2VuY3kiLCJpZCI6IjAifSx7Im5hbWUiOiJvcF9nYXRlZF9lY3Nfc3BvdF9pbnN0YW5jZSIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2l2YXNfdmNyX3ZjYSIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2FfY24tc291dGgtNGMiLCJpZCI6IjAifSx7Im5hbWUiOiJvcF9nYXRlZF9lY3Nfa2FlMSIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2ludGxfb2EiLCJpZCI6IjAifSx7Im5hbWUiOiJvcF9nYXRlZF9Lb29TZWFyY2hDT0JUIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfZHdzX3BvYyIsIm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:\\img\\idcode\\555.jpg";

        try {
            File file1 = transferToFile(file);
            // Create post
            HttpPost httpPost = new HttpPost(url);

            // Add header parameters
            httpPost.setHeader("X-Auth-Token", String.valueOf(token));

            // Add a body if you have specified the PUT or POST method. Special characters, such as the double quotation mark ("), contained in the body must be escaped.
//            File file = new File(filePath);
            HttpEntity entity = MultipartEntityBuilder.create().addBinaryBody("images", file1).setContentType(ContentType.MULTIPART_FORM_DATA).setCharset(Consts.UTF_8).build();
            httpPost.setEntity(entity);

            // Send post
            CloseableHttpResponse response = HttpClients.createDefault().execute(httpPost);

//            System.out.println(response.getStatusLine().getStatusCode());
//            System.out.println(EntityUtils.toString(response.getEntity()));

            int statusCode = response.getStatusLine().getStatusCode();
            if (Objects.equals(200,statusCode)){
                String string = EntityUtils.toString(response.getEntity());
                System.out.println(string);
                JSONObject jsonObject = JSONObject.parseObject(string);
                String detection_boxes = jsonObject.getString("detection_boxes");
                List<String> jsonObjects = JSONObject.parseArray(detection_boxes, String.class);
                if (!CollectionUtils.isEmpty(jsonObjects)){
                    String s = jsonObjects.get(0);
                    List<String> strings = JSONObject.parseArray(s, String.class);
                    return strings.get(1);

                }else {
                    return commonCode;
                }
            }else return commonCode;

        } catch (Exception e) {
            e.printStackTrace();
        }
        return commonCode;
    }



    @PostMapping("/parseTel")
    public void parseTel(String codeUrl,Long id) {
//
//        String codeUrl = MapUtils.getString(params, "codeUrl");
//        Long id = MapUtils.getLong(params, "id");

        TelUnbind tu = telUnbindMapper.selectTelUnbindByAccountId(id);
        if (Objects.isNull(tu)){
            return;
        }
        String securityPhone = tu.getCheckTel();
        if (StringUtils.isEmpty(securityPhone)){
            return;
        }
        //1、解析图片 获取手机号数字
        String resultTel = parseText(codeUrl);
        String REGEX = "[^(0-9)]";
        String ticket = Pattern.compile(REGEX).matcher(resultTel).replaceAll("").trim();

        //2、验证手机号是否正确
        System.out.println(ticket);
        String firstTel = securityPhone.substring(0, 3);
        String firstResult = ticket.substring(0, 3);

        String last = securityPhone.substring(securityPhone.length()-2, securityPhone.length());
        String lastResult = ticket.substring(ticket.length()-2, ticket.length());

        System.out.println(firstTel);
        System.out.println(firstResult);

        //入库错误信息
        TelUnbind telUnbind = telUnbindMapper.selectTelUnbindByAccountId(id);
        if (!(Objects.equals(firstTel,firstResult) && Objects.equals(last,lastResult))){
            if (Objects.nonNull(telUnbind)){
                StringBuilder sb = new StringBuilder(ticket);
                sb.insert(3, "------");
                telUnbind.setCurrentTel(sb.toString());
                telUnbind.setStatus("1");
            }
        }else {
            telUnbind.setStatus("2");
        }

        telUnbindMapper.updateTelUnbind(telUnbind);

        //3、不正确发送邮箱
    }



    private File transferToFile(MultipartFile multipartFile) {
//        选择用缓冲区来实现这个转换即使用java 创建的临时文件 使用 MultipartFile.transferto()方法 。
        File file = null;
        try {
            String originalFilename = multipartFile.getOriginalFilename();
            String[] filename = originalFilename.split("\\.");
            file=File.createTempFile(filename[0], filename[1]);
            multipartFile.transferTo(file);
            file.deleteOnExit();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return file;
    }
    private String parseText(String path) {

        SysDictData sysDictData = new SysDictData();
        sysDictData.setDictType("aly_access");
        sysDictData.setStatus(Constants.STR_0);
        List<SysDictData> sysDictDataList = sysDictDataMapper.selectDictDataList(sysDictData);
        String accessKeyId = "";
        String accessKeySecret = "";
        if (!CollectionUtils.isEmpty(sysDictDataList)) {
            for (SysDictData dictData : sysDictDataList) {
                if (Objects.equals(dictData.getDictLabel(), "accessKeyId")) {
                    accessKeyId = dictData.getDictValue();
                }
                if (Objects.equals(dictData.getDictLabel(), "accessKeySecret")) {
                    accessKeySecret = dictData.getDictValue();
                }
            }
        }
        try {
            String result = Sample.parseText(accessKeyId, accessKeySecret, path);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        try {
            String tel = "15225247351";
            String result = Sample.parseText("LTAI4Fz5S8QLbyB92ZeyHFwz", "kAzZh0hbiX2hNxpF8ZqD6hDyNzb0uv", "https://game.ikbh.top/.img0demo/fe39ab57ebc015129c2a4005e1901c3.jpg");

            System.out.println(result);
            String REGEX = "[^(0-9)]";
            String ticket = Pattern.compile(REGEX).matcher(result).replaceAll("").trim();
            System.out.println(ticket);
            String firstTel = tel.substring(0, 3);
            String firstResult = ticket.substring(0, 3);
            System.out.println(firstTel);
            System.out.println(firstResult);


            String last = tel.substring(tel.length()-2, tel.length());
            String lastResult = ticket.substring(ticket.length()-2, ticket.length());
            System.out.println(last);
            System.out.println(lastResult);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
